using System;

namespace Be.Timvw.Framework.ComponentModel
{
    public class GenericComparableAddress : IComparable<GenericComparableAddress>, IEquatable<GenericComparableAddress>
    {
        private string location;

        public GenericComparableAddress(string location)
        {
            this.location = location;
        }

        public string Location
        {
            get { return this.location; }
            set { this.location = value; }
        }

        #region IComparable<AddressGenericComparable> Members

        public int CompareTo(GenericComparableAddress other)
        {
            return this.location.CompareTo(other.location);
        }

        #endregion

        #region IEquatable<AddressGenericComparable> Members

        public bool Equals(GenericComparableAddress other)
        {
            return this.Equals((object) other);
        }

        #endregion

        public override bool Equals(object obj)
        {
            GenericComparableAddress other = obj as GenericComparableAddress;
            
            if(other == null)
            {
                return false;
            }

            return this.CompareTo(other) == 0;
        }

        public override int GetHashCode()
        {
            return this.location.GetHashCode();
        }
    }
}